<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <%@include file="../../common.jsp"%>
    <title>查看巡检任务</title>
    <style>
        .top{
            border: 1px solid #999999;
        }
        .bottom{
            border: 1px solid #999999;
            margin-top: 20px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
<div class="top">
<form class="layui-form" lay-filter="taskForm" id="taskForm" action="" style="padding:15px 10px;">
    <input type="hidden" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">任务编号:</label>
        <div class="layui-input-inline">
            <input type="text" name="inspectionTaskCode" required readonly  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">任务名称:</label>
        <div class="layui-input-inline">
            <input type="text" name="inspectionTaskName" required  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">巡检线路:</label>
        <div class="layui-input-inline">
            <input type="hidden" name="lineId">
            <input type="text" name="lineName" required  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">起始杆号:</label>
        <div class="layui-input-inline">
            <input type="text" name="startPoleCode" required readonly  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            <input type="hidden" name="startPoleId">
        </div>
        <label class="layui-form-label">终止杆号:</label>
        <div class="layui-input-inline">
            <input type="text" name="endPoleCode" required readonly  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            <input type="hidden" name="endPoleId">
        </div>
        <label class="layui-form-label">下发人:</label>
        <div class="layui-input-inline">
            <input type="text" name="issuedByName" class="layui-input" readonly style="border: 0px;">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">下发日期:</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" disabled id="issuedTime" name = "issuedTime">
        </div>
        <label class="layui-form-label">任务状态:</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" readonly name = "taskStateName">
        </div>
        <label class="layui-form-label">任务完成时间:</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" readonly name = "finishTime">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注信息:</label>
        <div class="layui-input-inline">
            <textarea name="common" cols="100" rows="2"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">巡检员:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" readonly name = "inspectors">
        </div>
    </div>
</form>
</div>

<div class="bottom">
<form class="layui-form" lay-filter="poleForm" id="poleForm" action="" style="padding:15px 10px;">
    <div class="layui-container">
        <div class="layui-row">
            <div class="layui-col-xs3">
                <div class="grid-demo grid-demo-bg1">
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <select name="lineId" id="line" width="300px" lay-filter="line">
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs9">
                <div class="grid-demo">
                    <input type="hidden" name="id">
                    <div class="layui-form-item">
                        <label class="layui-form-label">线路编码:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="lineCode" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">杆塔编号:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="poleCode" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">有无故障:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="isBug" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">完好率:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="intactRate" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">缺陷类型:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="bugTypeName" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">缺陷级别:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="bugLevelName" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">缺陷描述:</label>
                        <div class="layui-input-block">
                            <input type="text" name="bugDesc" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">巡检时间:</label>
                        <div class="layui-input-block">
                            <input type="text" name="inspectTime" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">巡检员:</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" readonly name = "inspectors">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">缺陷发现人:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="discovererName" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">发现时间:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="discoveTime" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">下发人员:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="discovererName2" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">下发时间:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="issuedTime" required readonly  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div>
        <button type="button" class="layui-btn layui-btn-normal" onclick="fanhui()">返回</button>
    </div>
</form>
</div>
<script>

    //返回上一级页面
    function fanhui(){
        history.go(-1);
    }
    var people;//下发人
    var time;//下发时间
    layui.use(["form","table"],function () {
        $.get("/task/get",{"taskId":${sessionScope.taskId}},function (data) {
            var lineName = data.lineName;//线路名称
            layui.form.val("taskForm",data)
            people = data.issuedByName;
            time = data.issuedTime;
            //完成时间
            if(data.finishTime == null){
                $(":input[name = 'finishTime']").val("尚未完成");
            }

            //赋值线路杆塔
            $.get("${path}/taskDetail/getLinePole",{"lineId":data.lineId},function (data) {
                //第一个为线路名称
                var option = $('<option></option>').appendTo("#line");
                option.text(lineName);

                $.each(data,function () {
                    var option = $('<option></option>').appendTo("#line");
                    option.text(this.poleCode).val(this.id);
                });
                layui.form.render();
            });
        })

        //下拉框选择事件
        layui.form.on('select(line)', function(data){
            var poleId = data.value;
            //根据杆塔编号查询杆塔信息
            $.get("/task/getPole",{"poleId":poleId},function (data) {
                layui.form.val("poleForm",data);
                //下发人
                $(":input[name = 'discovererName2']").val(people);
                //下发时间
                $(":input[name = 'issuedTime']").val(time);
                if(data.inspectTime == null){
                    $(":input[name = 'inspectTime']").val("尚未巡检");
                }
                if(data.isBug == null){
                    $(":input[name = 'isBug']").val("暂无故障");
                }
            })
        });
    })


</script>
</body>
</html>